import Vue from 'vue'
import Vuex from 'vuex'
import http from '@/api/user'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    flag1: false,
    flag2: false,
    flag3: false,
    // 存储token
    token: '',
  },
  getters: {
    getToken(state){
      return state.token || localStorage.getItem("token") || "";
    },
  },
  mutations: {
    setToken(state, token) {
      state.token = token
      localStorage.setItem('token', token)
    },
    delToken(state) {
      state.token = ''
      localStorage.removeItem('token')
    },
    setAdd(state) {
      state.flag1 = !state.flag1
    },
    setFlag(state) {
      state.flag2 = !state.flag2
      //console.log(state.flag)
    },
    setDistr(state) {
      state.flag3 = !state.flag3
    },
  },
  actions: {
  },
  modules: {

  }
})
